package sindconsole.auth.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import sindconsole.auth.bean.Account;
import sindconsole.auth.bean.User;

import java.util.List;

@Mapper
public interface AccountMapper extends BaseMapper<Account> {

    @Select("select * from account where user_id=#{userId}")
    List<Account> selectByUserId(@Param("userId") long userId);

    @Select("select u.* from account a, user u where a.user_id=u.id and a.username=#{username}")
    User selectUserByUsername(@Param("username") String username);

    @Update("update account set password=#{password} where user_id=#{userId}")
    int updatePasswordByUserId(@Param("userId") long userId, @Param("password") String password);

}
